Vue.component("head-template", Vue.extend({
    template: '<div class="sy_headBox">\n' +
        '    <div class="sy_top">\n' +
        '        <div class="sy_top_con">\n' +
        '            <img src="/images/title_logo.png" class="fl" onclick="javascript:location.href= \'/index.html\'"/>\n' +
        '            <span class="user_name">欢迎您！</span>|\n' +
        '            <a href="/logout">注销</a>\n' +
        '            <a href="/system/manage-analyze.html">后台管理</a>' +
        '        </div>\n' +
        '    </div>\n' +
        '    <div class="sy_slogin"><img src="/images/logo.png"/></div>\n' +
        '</div>'
}));

Vue.component("system-menu-template",Vue.extend({
    data:function(){

    },
    props:['activeMenu'],
    template: '<div class="leftside fl w162">\n' +
        '                <div class="left-bg"></div>\n' +
        '                <h1 class="left-title"><span>ADMIN <strong>CENTER</strong></span>\n' +
        '                    <p>- 管理中心 -</p></h1>\n' +
        '                <ul class="left-nav">\n' +
        '                    <li class="first-nav"><a :class="{active:activeMenu == 0}" href="manage-analyze.html">图表分析</a></li>\n' +
        '                    <li class="first-nav"><a :class="{active:activeMenu == 1}" href="manage-user.html">用户管理</a></li>\n' +
        '                    <li><a :class="{active:activeMenu == 2}" href="manage-role.html">角色管理</a></li>\n' +
        '                    <li><a :class="{active:activeMenu == 3}" href="manage-log.html">操作日志</a></li>\n' +
        '                </ul>\n' +
        '            </div>'
}));

Vue.component("page-template",Vue.extend({
    data:function(){

    },
    props:['totalCount','queryData','pageCount'],
    template:'<div class="pages">\n' +
        '                    <div class="resultP">共{{totalCount}}条结果</div>\n' +
        '                    <div class="resultP">当前第<span>{{queryData.pageNum}}</span>页 共{{pageCount}}页</div>\n' +
        '                    <div class="pagenav">\n' +
        '                        <a href="javascript:void(0);" v-on:click="goPage(\'First\')"\n' +
        '                           class="page-first disable">首页</a>\n' +
        '                        <a href="javascript:void(0);"\n' +
        '                           v-on:click="goPage(\'Previous\')"\n' +
        '                           class="page-prev disable">上一页</a>\n' +
        '                        <a href="javascript:void(0);" v-on:click="goPage(\'Next\')"\n' +
        '                           class="page-next">下一页</a>\n' +
        '                        <a href="javascript:void(0);" v-on:click="goPage(\'Last\')"\n' +
        '                           class="page-last">尾页</a>\n' +
        '                    </div>\n' +
        '                    <input class="inputTxt c_num" type="text" name="" id="" value="1">\n' +
        '                    <input type="button" class="inputBtn" value="GO"\n' +
        '                           v-on:click="gotoPage()"/>\n' +
        '                </div>',
    methods:{
        goPage(operation) {//上一页下一页
            if (operation == "First") {
                this.queryData.pageNum = 1;
            } else if (operation == "Previous" && this.queryData.pageNum > 1) {
                this.queryData.pageNum--;
            } else if (operation == "Next" && this.queryData.pageNum < this.pageCount) {
                this.queryData.pageNum++;
            } else if (operation == "Last") {
                this.queryData.pageNum = this.pageCount;
            }
            this.$parent.searchData();
        },
        gotoPage() {//跳到第几页
            let pageCount = this.totalCount;
            let pageNumber = parseInt($.trim($('.c_num').val()));
            let ex = /^[0-9]*[1-9][0-9]*$/;
            if (pageNumber == "" || pageNumber > pageCount || pageNumber < 1 || !ex.test(pageNumber)) {
                return;
            }
            this.queryData.pageNum = pageNumber;
            this.$parent.searchData();
        }
    }
}))